package com.itsci.assignment2;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class AddVehicle extends Activity{
	private EditText name;
	private EditText price;
	private VehicleManager vehiMgr;
	private Button bnt;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.add_vehicle);
		name = (EditText)findViewById(R.id.editText_add_vehicle_name);
		price = (EditText)findViewById(R.id.editText_add_vehicle_price);
		vehiMgr = new VehicleManager(AddVehicle.this, null,null,1);
		bnt = (Button)findViewById(R.id.button_add_vehicle_save);
		bnt.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				VehicleBean  vb = new VehicleBean(name.getText().toString(),Integer.parseInt(price.getText().toString()));
				vehiMgr.insertVehicle(vb);
				Intent gotoListGuide = new Intent(AddVehicle.this,ListVehicle.class);
				startActivity(gotoListGuide);
			}
		});
		
	}

}
